package github.kawaiior.yuanchuxiuzhen.common.item.misc;

import github.kawaiior.yuanchuxiuzhen.common.capability.entity.ManaPower;
import github.kawaiior.yuanchuxiuzhen.core.init.itemgroup.YcxzGroup;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;

import javax.annotation.Nullable;
import java.util.List;

public class JadeSlipsItem extends Item {

    /**
     * 0: 子位
     * 1: 卯位
     * 2: 午位
     * 3: 酉位
     */
    private final Item[] itemArray;
    private final int[] itemCount;
    private final int fireLevel;
    private final ManaPower.ManaRoot manaRoot;
    private final Item[] products;

    public JadeSlipsItem(Item[] itemArray, int[] itemCount, int fireLevel, ManaPower.ManaRoot manaRoot, Item[] products) {
        super(new Properties().group(YcxzGroup.YCXZ_GROUP).maxStackSize(1));
        this.itemArray = itemArray;
        this.itemCount = itemCount;
        this.fireLevel = fireLevel;
        this.manaRoot = manaRoot;
        this.products = products;
    }

    public JadeSlipsItem(Item[] itemArray, int[] itemCount, int fireLevel, ManaPower.ManaRoot manaRoot, Item product) {
        this(itemArray, itemCount, fireLevel, manaRoot, new Item[]{product});
    }

    @Override
    public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
        super.addInformation(stack, worldIn, tooltip, flagIn);
        tooltip.add(new TranslationTextComponent("ycxz.jade_slips.recipe.5", fireLevel));
        tooltip.add(new TranslationTextComponent("ycxz.jade_slips.recipe.4", manaRoot.toString()));
        for (int i = 0; i < itemCount.length; i++) {
            tooltip.add(new TranslationTextComponent("ycxz.jade_slips.recipe."+i, itemArray[i].getName(), itemCount[i]));
        }
    }

    public Item[] getItemArray() {
        return itemArray;
    }

    public int[] getItemCount() {
        return itemCount;
    }

    public int getFireLevel() {
        return fireLevel;
    }

    public ManaPower.ManaRoot getManaRoot() {
        return manaRoot;
    }

    public Item[] getProducts() {
        return products;
    }
}
